package special_tree;

import compiler.CompilerException;

import code.CodeList;
import code.Opcode;
import lexer.Token;
import tree.DataType;
import tree.MyTree;
import tree.Tree;
import tree.Type;
import tree.TypingException;

public class CondTree extends MyTree {

	public CondTree(Token token, Tree... operands) {
		super(token, operands);
	}

	/* (non-Javadoc)
	 * @see tree.MyTree#computeType()
	 */
	@Override
	@Deprecated
	public Type computeType() throws TypingException {
		this.expectType(this.getOperand(0), new Type(DataType.BOOL,""));
		return this.expectSameType(getOperand(1), getOperand(2));
	}

	/* (non-Javadoc)
	 * @see tree.MyTree#generateCode(code.CodeList)
	 */
	@Override
	@Deprecated
	public void generateCode(CodeList code) throws CompilerException {
		getOperand(2).generateCode(code);
		getOperand(1).generateCode(code);
		getOperand(0).generateCode(code);
		code.generateCode(Opcode.SEL);
	}

}
